package com.tang.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author tang jun liang
 * @Date 2023-04-25 15:38:36
 */
@Getter
public enum UserStatus {
    /**
     * 用户状态
     */
    ENABLE(1101, "启用"),

    DISABLED(1001, "禁用"),

    FREEZE(1201, "冻结"),

    UNKNOWN(0, "未知")
    ;


    @JsonValue
    @EnumValue
    private final Integer value;

    private final String desc;

    UserStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    @JsonCreator
    public static UserStatus create(Integer value){
        for (UserStatus item: values()){
            if (item.getValue().equals(value)){
                return item;
            }
        }
        return UNKNOWN;
    }

}
